package com.huang.service;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.huang.dao.AdminMapper;
import com.huang.pojo.*;

import java.util.List;

public class AdminServiceImpl implements AdminService {

    private AdminMapper adminMapper;
    public void setAdminMapper(AdminMapper adminMapper) {
        this.adminMapper=adminMapper;
    }

    public Admin loginAdmin(Admin admin) {
        return adminMapper.loginAdmin(admin);
    }

    @Override
    public int improveAdmin(Admin admin) {
        return adminMapper.improveAdmin(admin);
    }

    @Override
    public List<Teacher> showAllTeacher() {
        return adminMapper.showAllTeacher();
    }

    @Override
    public List<Teacher> showAllTeacherByPage01(int page, int pageSize) {
        //开启分页支持
        PageHelper.startPage(page,pageSize);
        //调用dao层查询所有
        List<Teacher> list=adminMapper.showAllTeacher();
        //获取分页的相关信息
        PageInfo pageInfo=new PageInfo(list);
        System.out.println("当前页数"+pageInfo.getPageNum());
        System.out.println("总页数"+pageInfo.getPages());
        System.out.println("每页条数"+pageInfo.getPageSize());
        System.out.println("总记录数"+pageInfo.getTotal());
        System.out.println("获取第一页"+pageInfo.getNavigateFirstPage());
        System.out.println("获取最后一页"+pageInfo.getNavigateLastPage());
        System.out.println("上一页"+pageInfo.getPrePage());
        System.out.println("下一页"+pageInfo.getNextPage());
        System.out.println("当前页数据"+pageInfo.getList().size());

        return list;
    }

    @Override
    public PageInfo<Teacher> showAllTeacherByPage(int page, int pageSize) {
        //开启分页支持
        PageHelper.startPage(page,pageSize);
        //调用dao层查询所有
        List<Teacher> list=adminMapper.showAllTeacher();
        //获取分页的相关信息
        PageInfo pageInfo=new PageInfo(list);
        return pageInfo;
    }

    @Override
    public List<Student> showAllStudent() {
        return adminMapper.showAllStudent();
    }

    @Override
    public List<Activity> showAllActivity() {
        return adminMapper.showAllActivity();
    }

    @Override
    public int issueNotice(Announcement announcement) {
        return adminMapper.issueNotice(announcement);
    }

    @Override
    public List<Announcement> historyNotice() {
        return adminMapper.historyNotice();
    }

    @Override
    public List<Announcement> myNotice(Admin admin) {
        return adminMapper.myNotice(admin);
    }

    @Override
    public int expiredNotice(Announcement announcement) {
        return adminMapper.expiredNotice(announcement);
    }

    @Override
    public List<FeedBack> showUserFeedBack(Announcement announcement) {
        return adminMapper.showUserFeedBack(announcement);
    }

    @Override
    public List<Student> findStuByNo(Student student) {
        return adminMapper.findStuByNo(student);
    }

    @Override
    public List<Teacher> findTeaByNo(Teacher teacher) {
        return adminMapper.findTeaByNo(teacher);
    }

    @Override
    public List<Activity> findActivityByTea(Teacher teacher) {
        return adminMapper.findActivityByTea(teacher);
    }

    @Override
    public int addTeacher(Teacher teacher) {
        return adminMapper.addTeacher(teacher);
    }

    @Override
    public Teacher findTeacherByNo(Teacher teacher) {
        return adminMapper.findTeacherByNo(teacher);
    }

    @Override
    public List<Teacher> showSelfTea(Admin admin) {
        return adminMapper.showSelfTea(admin);
    }

    @Override
    public int removeSelfTea(Teacher teacher) {
        return adminMapper.removeSelfTea(teacher);
    }

    @Override
    public Admin findAdminByName(Admin admin) {
        return adminMapper.findAdminByName(admin);
    }

    @Override
    public List<Admin> showAllAdmin() {
        return adminMapper.showAllAdmin();
    }

    @Override
    public List<Announcement> findAnnounceByAdminName(Admin admin) {
        return adminMapper.findAnnounceByAdminName(admin);
    }

    @Override
    public List<Teacher> findTeacherByAdminName(Admin admin) {
        return adminMapper.findTeacherByAdminName(admin);
    }

    @Override
    public List<UserDiary> adminViewDiary(Admin admin) {
        return adminMapper.adminViewDiary(admin);
    }
}
